package nl.nickthissen.remindme.views;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.RectF;
import android.util.AttributeSet;
import android.widget.Button;
import android.widget.FrameLayout;

import nl.nickthissen.remindme.common.CategoryColors;

/**
 * Created by nthissen on 11/06/13.
 */
public class ColorButton extends FrameLayout
{
    private Paint paint;

    public ColorButton(Context context)
    {
        super(context);
        color = CategoryColors.getDefaultColor();
        paint = new Paint(Paint.ANTI_ALIAS_FLAG);
        paint.setStyle(Paint.Style.FILL);
    }

    private int color;
    public int getColor() { return this.color; }
    public void setColor(int color) { this.color = color;}

    @Override
    public void onDraw(Canvas canvas)
    {
        int w = getWidth();
        int h = getHeight();

        float xpad = (float)(getPaddingLeft() + getPaddingRight());
        float ypad = (float)(getPaddingTop() + getPaddingBottom());

        float ww = (float)w - xpad;
        float hh = (float)h - ypad;

        float radius = Math.min(ww, hh) / 2;

        paint.setColor(color);
        canvas.drawCircle(ww/2, hh/2, radius, paint);
    }
}
